﻿package mortal.game.net.command.friendBless
{
    import Framework.MQ.*;
    import Message.Command.*;
    import Message.Game.*;
    import com.gengine.debug.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.net.broadCast.*;
    import mortal.mvc.core.*;

    public class FriendBlessCommand extends BroadCastCall
    {

        public function FriendBlessCommand(param1:Object)
        {
            super(param1);
            return;
        }// end function

        override public function call(param1:MessageBlock) : void
        {
            var _loc_2:SCanCongratulateMsg = null;
            var _loc_3:SCongratulateMsg = null;
            var _loc_4:SCongratulateInfoMsg = null;
            Log.debug("I have receive FriendBlessCommand");
            super.call(param1);
            switch(param1.messageHead.command)
            {
                case EGateCommand._ECmdGateFriendCanCongratulate:
                {
                    _loc_2 = param1.messageBase as SCanCongratulateMsg;
                    Cache.instance.friendBless.addFriendCongratulation(_loc_2.canCongratulatePlayers);
                    NetDispatcher.dispatchCmd(ServerCommand.FriendBlessGetCanBlessInfo, _loc_2);
                    break;
                }
                case EGateCommand._ECmdGateFriendCongratulate:
                {
                    _loc_3 = param1.messageBase as SCongratulateMsg;
                    if (_loc_3.fromPlayer.entityId.id == Cache.instance.role.entityInfo.entityId.id && _loc_3.result == ECongratulateResult._ECongratulateSucess)
                    {
                        Cache.instance.friendBless.updateCongratulateList(_loc_3.toPlayer);
                        Dispatcher.dispatchEvent(new DataEvent(EventName.FriendBlessBtnStateUpdate, _loc_3.toPlayer));
                    }
                    NetDispatcher.dispatchCmd(ServerCommand.FriendBlessResultInfo, _loc_3);
                    break;
                }
                case EGateCommand._ECmdGateFriendCongratulateInfo:
                {
                    _loc_4 = param1.messageBase as SCongratulateInfoMsg;
                    Cache.instance.friendBless.sCongratulateInfo = _loc_4;
                    NetDispatcher.dispatchCmd(ServerCommand.FriendBlessCongratulateInfo, _loc_4);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

    }
}
